package com.exchange.controller;

import com.exchange.entity.pojo.User;
import com.exchange.service.UserService;
import com.exchange.until.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 董慧珍
 * @Date 2024/04/25
 * @Version 1.0
 **/
@Slf4j
@RestController
@RequestMapping("/jeecg-boot")
@Tag(name = "个人中心")
public class PersonalController {
    @Autowired
    private UserService userService;
    /**
     * 个人中心列表
     * */
    @GetMapping("/personalList")
    @Operation(summary = "个人中心列表")
    public Result personalList(@RequestHeader String token) {
        User user = this.userService.selectPersonal(token);
        return Result.success(user);
    }
    /**
     * 个人信息修改
     * */
    @PostMapping("/personalUpdate")
    @Operation(summary = "个人信息修改")
    public Result personalUpdate(@RequestBody User user) {
        this.userService.personalUpdate(user);
        return Result.success(user);
    }

    /**
     * 修改密码时判断输入的旧密码是否一样
     * */
    @PostMapping("/findPassword")
    @Operation(summary = "判断输入的旧密码是否一样")
    public Result findPassword(@RequestBody User user,@RequestHeader String token) {
        boolean a=this.userService.findPassword(user,token);
        return  Result.success(a);
    }
    /**
     * 修改密码
     * */
    @PostMapping("/passwordUpdate")
    @Operation(summary = "修改密码")
    public Result passwordUpdate(@RequestBody User user,@RequestHeader String token) {
        boolean a=this.userService.passwordUpdate(user,token);
        return Result.success(a);
    }


}
